package com.bzkj.web.controller.msfx;

import com.bzkj.common.annotation.LogD;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import com.bzkj.msfx.domain.Logistics;
import com.bzkj.msfx.service.LogisticsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @projectName: btyy
 * @package: com.ruoyi.web.controller.basicinfo.msfx
 * @className: LogisticsController
 * @description: 配送单位控制层
 * @author: C1309
 * @createDate: 2024年03月27日
 * @version: v1.0
 */
@RestController
@RequestMapping("/btrh/basic/logistics")
public class LogisticsController extends BaseController {
    @Resource
    private LogisticsService logisticsService;

    /**
     * 获取配送单位列表
     *
     * @param logistics 查询条件
     * @return 配送单位列表
     */
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('basic:logistics:list')")
    public TableDataInfo getLogistics(Logistics logistics) {
        return logisticsService.queryLogistics(logistics);
    }

    /***
     * 新增配送单位
     *
     * @param logistics 配送单位
     * @return 新增结果
     */
    @PostMapping
    @PreAuthorize("@ss.hasPermi('basic:logistics:add')")
    @LogD(title = "码上放心配送单位", businessType = BusinessType.INSERT, pkFieldName = "logisticsName")
    public AjaxResult addLogistics(@RequestBody Logistics logistics) {
        return logisticsService.addLogistics(logistics);
    }

    /**
     * 删除配送单位
     *
     * @param id 配送单位数据编号
     * @return 删除结果
     */
    @DeleteMapping("/{id}")
    @PreAuthorize("@ss.hasPermi('basic:logistics:delete')")
    public AjaxResult deleteLogistics(@PathVariable("id") String id) {
        return logisticsService.deleteLogistics(id);
    }

    /**
     * 查询码上放心往来单位
     *
     * @return 查询结果
     */
    @GetMapping("/msfx")
    @PreAuthorize("@ss.hasPermi('basic:logistics:list')")
    public AjaxResult getMsfxDrugInfo() {
        return logisticsService.queryMsfxCustomerInfo();
    }
}
